import java.util.HashMap;
import java.util.Map;

public class Solution2284 {
    public String largestWordCount(String[] messages, String[] senders) {
        Map<String,Integer> map=new HashMap<>();
        for (int i=0;i<messages.length;i++){
            map.putIfAbsent(senders[i],0);
            map.put(senders[i],map.get(senders[i])+messages[i].split(" ").length);
        }
        int min=0;
        String ans="";
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue()>min || entry.getValue()==min && ans.compareTo(entry.getKey())<0){
                ans=entry.getKey();
                min=entry.getValue();
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2284().largestWordCount(new String[]{"Hello userTwooo","Hi userThree","Wonderful day Alice","Nice day userThree"},new String[]{"Alice","userTwo","userThree","Alice"}));
    }
}
